<template>
  <div class="index">
    <div class="waifu">
      <!-- 提示框 -->
      <div class="waifu-tips"></div>

      <!-- 看板娘画布 -->
      <canvas id="live2d" class="live2d" />

      <!-- 工具栏 -->
      <div class="waifu-tool">
        <p class="fui-home">
          <PlayCircleOutlined @click="$router.push('/work-place')" />
        </p>
        <p class="fui-home">
          <HomeOutlined @click="$router.push('/work-place')" />
        </p>
        <p class="fui-chat">
          <CloudUploadOutlined />
        </p>
        <p class="fui-eye">
          <SwapOutlined />
        </p>
        <p class="fui-user">
          <ExperimentOutlined />
        </p>
        <p class="fui-photo">
          <CameraOutlined />
        </p>
        <p class="fui-info-circle">
          <MessageOutlined />
        </p>
        <p class="fui-cross">
          <CloseOutlined />
        </p>
      </div>
    </div>
  </div>
</template>

<script setup>
import '@/assets/live2d/waifu-tips'
import '@/assets/live2d/live2d'
// import '@/assets/live2d/waifu.css'
import { initModel } from '@/assets/live2d/waifu-tips'

import waifuTipsJson from '@/assets/live2d/waifu-tips.json'

import { onMounted } from 'vue'

onMounted(() => {
  try {
    setTimeout(() => {
      live2d_settings['modelId'] = 5 // 默认模型 ID
      live2d_settings['modelTexturesId'] = 1 // 默认材质 ID
      /* 在 initModel 前添加 */
      initModel(waifuTipsJson)
    }, 1000)
  } catch (error) {
    setTimeout(() => {
      console.log('live2d正在重新加载...')
      live2d_settings['modelId'] = 5 // 默认模型 ID
      live2d_settings['modelTexturesId'] = 1 // 默认材质 ID
      initModel(waifuTipsJson)
    }, 1000)
  }
})
</script>

<style scoped>
@import url('../../assets/live2d/waifu.css');
.waifu-tool p i {
  cursor: pointer;
}
</style>
